<?PHP

  if (!function_exists('get_courses_wmanagers')) {
    
	// Pas d'accès direct à ce fichier, vérification de l'existence de la variable définie dans le fichier qui l'appelle
	$SECURITE="OK";
	
	// Config de Moodle
    include('../../../config.php');
    include('../../includes/config/config.php');
    include('../../includes/fonctions/fct.php');
  }
//Nbre d’étudiants distinct  total ".$CONF_bdd_prefixe."aua_etudiant_etape annee =2009 (via apogé)
$sql_etu_corresp = "SELECT distinct(NO_ETUDIANT) FROM ".$CONF_bdd_prefixe."aua_etudiant_etape` WHERE NO_ANNEE=".$CONF_annee_en_cours.""; 
$etu_corresp = mysql_query($sql_etu_corresp);
$nb_etu_corresp=mysql_num_rows($etu_corresp);
echo "<h2>Nb étudiants distinct ayant une etape ".$CONF_annee_en_cours." (année en cours) sur Apogé : ".$nb_etu_corresp."</h2>";
$sql_pers_corresp = "SELECT distinct(NO_INDIVIDU) FROM ".$CONF_bdd_prefixe."aua_personnel_etape` WHERE NO_ANNEE=".$CONF_annee_en_cours.""; 
$pers_corresp = mysql_query($sql_pers_corresp);
$nb_pers_corresp=mysql_num_rows($pers_corresp);
echo "<h2>Nb personnel distinct ayant une etape ".$CONF_annee_en_cours." (année en cours) sur Apogé : ".$nb_pers_corresp."</h2><br />";


/////////////////////////////////////////////
//Pourcentage de personnes jamais connectées 
/////////////////////////////////////////////
//On prend tous les utilisateurs de moodle
$sql_all = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user WHERE deleted=0"; 
$user_all = mysql_query($sql_all);
//On compte combien ils sont
$nb_user_all=mysql_num_rows($user_all);
//On prend tout les utilisateurs qui ne se sont jamais connecté
$sql_jamais_connecte = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user WHERE firstaccess=0 AND deleted=0";
$user_jamais_connecte = mysql_query($sql_jamais_connecte);
//On compte combien ils sont
$nb_user_jamais_connecte=mysql_num_rows($user_jamais_connecte);
//On calcule le pourcentage : (utilisateur jamais connecté / nombre d'utilisateur total) *100 et on arrondi a 2 chiffres 
$total_all=round(($nb_user_jamais_connecte/$nb_user_all)*100,2);


 /////////////// EMAIL /////////////
$sql_mail = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user where email LIKE '%@".$CONF_domaine."' AND deleted=0 ";  
$user_mail = mysql_query($sql_mail);
//On compte combien ils sont
$nb_user_mail=mysql_num_rows($user_mail);
$sql_mail_JC = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user where email LIKE '%@".$CONF_domaine."' AND firstaccess=0 AND deleted=0 ";  
$user_mail_JC = mysql_query($sql_mail_JC);
$nb_user_mail_JC=mysql_num_rows($user_mail_JC);
$total_mail_JC=round(($nb_user_mail_JC/$nb_user_mail)*100,2);


$sql_not_mail = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user where email NOT LIKE '%@".$CONF_domaine."' AND deleted=0 ";  
$user_not_mail = mysql_query($sql_not_mail);
//On compte combien ils sont
$nb_user_not_mail=mysql_num_rows($user_not_mail);
$sql_not_mail_JC = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user where email NOT LIKE '%@".$CONF_domaine."' AND firstaccess=0 AND deleted=0 ";  
$user_not_mail_JC = mysql_query($sql_not_mail_JC);
$nb_user_not_mail_JC=mysql_num_rows($user_not_mail_JC);
$total_not_mail_JC=round(($nb_user_not_mail_JC/$nb_user_not_mail)*100,2);


/////////////// ROLE ETUDIANT /////////////

//On recupere le nombre de personnes distinct qui ont un role étudiant et qui se sont connecté
$sql_user_etu = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."user, ".$CONF_moodle_bdd_prefixe."role_assignments WHERE ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND roleid=".$CONF_role_etudiant." AND deleted=0 ";
$user_etu = mysql_query($sql_user_etu);
//On compte combien ils sont
$nb_users_etu=mysql_num_rows($user_etu);
$sql_user_etu_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."user, ".$CONF_moodle_bdd_prefixe."role_assignments WHERE ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND roleid=".$CONF_role_etudiant." AND deleted=0  AND firstaccess=0";
$user_etu_JC = mysql_query($sql_user_etu_JC);
//On compte combien ils sont
$nb_users_etu_JC=mysql_num_rows($user_etu_JC);
$total_role_etu_JC=round(($nb_users_etu_JC/$nb_users_etu)*100,2);


//On recupere le nombre de personnes distinct qui ont un role étudiant et qui se sont connecté
$sql_user_not_etu = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."user, ".$CONF_moodle_bdd_prefixe."role_assignments WHERE ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND roleid!=".$CONF_role_etudiant." AND deleted=0 ";
$user_not_etu = mysql_query($sql_user_not_etu);
//On compte combien ils sont
$nb_users_not_etu=mysql_num_rows($user_not_etu);

// ROLE ENSEIGNANT JAMAIS CONNECTES
$sql_user_not_etu_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."user, ".$CONF_moodle_bdd_prefixe."role_assignments WHERE ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND roleid!=".$CONF_role_etudiant." AND deleted=0  AND firstaccess=0";
$user_etu_not_JC = mysql_query($sql_user_not_etu_JC);
//On compte combien ils sont
$nb_users_not_etu_JC=mysql_num_rows($user_etu_not_JC);
$total_role_not_etu_JC=round(($nb_users_not_etu_JC/$nb_users_not_etu)*100,2);

/////////////// ROLE ENSEIGNANT /////////////

// ROLE ENSEIGNANT
$sql_user_prof = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."user, ".$CONF_moodle_bdd_prefixe."role_assignments WHERE ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND roleid=".$CONF_role_enseignant." AND deleted=0 ";
$user_prof = mysql_query($sql_user_prof);
//On compte combien ils sont
$nb_users_prof=mysql_num_rows($user_prof);
// ROLE ENSEIGNANT JAMAIS CONNECTES
$sql_user_prof_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."user, ".$CONF_moodle_bdd_prefixe."role_assignments WHERE ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND roleid=".$CONF_role_enseignant." AND deleted=0  AND firstaccess=0";
$user_prof_JC = mysql_query($sql_user_prof_JC);
//On compte combien ils sont
$nb_users_prof_JC=mysql_num_rows($user_prof_JC);
$total_role_prof_JC=round(($nb_users_prof_JC/$nb_users_prof)*100,2);

// EMAIL ROLE ENSEIGNANT
$sql_email_role_prof = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email LIKE '%@".$CONF_domaine."' AND deleted=0  AND roleid=".$CONF_role_enseignant;  
$user_email_role_prof = mysql_query($sql_email_role_prof);
//On compte combien ils sont
$nb_user_email_role_prof=mysql_num_rows($user_email_role_prof);
// EMAIL ROLE ENSEIGNANT  JAMAIS CONNECTES
$sql_email_role_prof_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email LIKE '%@".$CONF_domaine."' AND deleted=0 AND firstaccess=0 AND roleid=".$CONF_role_enseignant;  
$user_email_role_prof_JC = mysql_query($sql_email_role_prof_JC);
//On compte combien ils sont
$nb_user_email_role_prof_JC=mysql_num_rows($user_email_role_prof_JC);
$total_email_role_prof_JC=round(($nb_user_email_role_prof_JC/$nb_user_email_role_prof)*100,2);

// PAS EMAIL ROLE ENSEIGNANT
$sql_not_email_role_prof = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email NOT LIKE '%@".$CONF_domaine."' AND deleted=0  AND roleid=".$CONF_role_enseignant;  
$user_not_email_role_prof = mysql_query($sql_not_email_role_prof);
//On compte combien ils sont
$nb_user_not_email_role_prof=mysql_num_rows($user_not_email_role_prof);
// EMAIL ROLE ENSEIGNANT  JAMAIS CONNECTES
$sql_not_email_role_prof_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email NOT LIKE '%@".$CONF_domaine."' AND deleted=0 AND firstaccess=0 AND roleid=".$CONF_role_enseignant;  
$user_not_email_role_prof_JC = mysql_query($sql_not_email_role_prof_JC);
//On compte combien ils sont
$nb_user_not_email_role_prof_JC=mysql_num_rows($user_not_email_role_prof_JC);
$total_not_email_role_prof_JC=round(($nb_user_not_email_role_prof_JC/$nb_user_not_email_role_prof)*100,2);



//////////////////////////////////////////
// EMAIL ROLE ETU  
$sql_email_role_etu = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email LIKE '%@".$CONF_domaine."' AND deleted=0  AND roleid=".$CONF_role_etudiant;  
$user_email_role_etu = mysql_query($sql_email_role_etu);
//On compte combien ils sont
$nb_user_email_role_etu=mysql_num_rows($user_email_role_etu);
// EMAIL ROLE ETU  JAMAIS CONNECTES
$sql_email_role_etu_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email LIKE '%@".$CONF_domaine."' AND deleted=0 AND firstaccess=0 AND roleid=".$CONF_role_etudiant;  
$user_email_role_etu_JC = mysql_query($sql_email_role_etu_JC);
//On compte combien ils sont
$nb_user_email_role_etu_JC=mysql_num_rows($user_email_role_etu_JC);
$total_email_role_etu_JC=round(($nb_user_email_role_etu_JC/$nb_user_email_role_etu)*100,2);

// PAS EMAIL ROLE ETU 
$sql_not_email_role_etu = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email NOT LIKE '%@".$CONF_domaine."' AND deleted=0  AND roleid=".$CONF_role_etudiant;  
$user_not_email_role_etu = mysql_query($sql_not_email_role_etu);
//On compte combien ils sont
$nb_user_not_email_role_etu=mysql_num_rows($user_not_email_role_etu);
// PAS EMAIL ROLE ETU  JAMAIS CONNECTES
$sql_not_email_role_etu_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email NOT LIKE '%@".$CONF_domaine."' AND deleted=0 AND firstaccess=0 AND roleid=".$CONF_role_etudiant;  
$user_not_email_role_etu_JC = mysql_query($sql_not_email_role_etu_JC);
//On compte combien ils sont
$nb_user_not_email_role_etu_JC=mysql_num_rows($user_not_email_role_etu_JC);
$total_not_email_role_etu_JC=round(($nb_user_not_email_role_etu_JC/$nb_user_not_email_role_etu)*100,2);


//EMAIL PAS DE ROLE ETU NI ENSEIGNANT 
$sql_email_not_role = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email LIKE '%@".$CONF_domaine."' AND deleted=0 AND roleid!=".$CONF_role_enseignant."  AND roleid!=".$CONF_role_etudiant;  
$user_email_not_role = mysql_query($sql_email_not_role);
//On compte combien ils sont
$nb_user_email_not_role=mysql_num_rows($user_email_not_role);
//EMAIL PAS DE ROLE ETU NI ENSEIGNANT  JAMAIS CONNECTES
$sql_email_not_role_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email LIKE '%@".$CONF_domaine."' AND deleted=0 AND firstaccess=0 AND roleid!=".$CONF_role_enseignant."  AND roleid!=".$CONF_role_etudiant;  
$user_email_not_role_JC = mysql_query($sql_email_not_role_JC);
//On compte combien ils sont
$nb_user_email_not_role_JC=mysql_num_rows($user_email_not_role_JC);
$total_email_not_role_JC=round(($nb_user_email_not_role_JC/$nb_user_email_not_role)*100,2);


//PAS EMAIL PAS DE ROLE ETU NI ENSEIGNANT
$sql_not_email_not_role = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email NOT LIKE '%@".$CONF_domaine."' AND deleted=0  AND roleid!=".$CONF_role_enseignant." AND roleid!=".$CONF_role_etudiant;  
$user_not_email_not_role = mysql_query($sql_not_email_not_role);
//On compte combien ils sont
$nb_user_not_email_not_role=mysql_num_rows($user_not_email_not_role);
//PAS EMAIL PAS DE ROLE ETU NI ENSEIGNANT  JAMAIS CONNECTES
$sql_not_email_not_role_JC = "SELECT DISTINCT(userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments, ".$CONF_moodle_bdd_prefixe."user where ".$CONF_moodle_bdd_prefixe."role_assignments.userid=".$CONF_moodle_bdd_prefixe."user.id AND email NOT LIKE '%@".$CONF_domaine."' AND deleted=0 AND firstaccess=0 AND roleid!=".$CONF_role_enseignant." AND roleid!=".$CONF_role_etudiant;  
$user_not_email_not_role_JC = mysql_query($sql_not_email_not_role_JC);
//On compte combien ils sont
$nb_user_not_email_not_role_JC=mysql_num_rows($user_not_email_not_role_JC);
$total_not_email_not_role_JC=round(($nb_user_not_email_not_role_JC/$nb_user_not_email_not_role)*100,2);


echo "<table class='ui-widget ui-widget-content'>
<tr>
  <td><strong>".$nb_user_all." Utilisateurs</strong> <br />(".$nb_user_jamais_connecte." jamais connectés : ".$total_all." %)</td>
  <td><strong>".$nb_user_mail." Avec @".$CONF_domaine."</strong> <br />(".$nb_user_mail_JC." jamais connectés : ".$total_mail_JC." %)</td>
  <td><strong>".$nb_user_not_mail." Sans @".$CONF_domaine."</strong> <br />(".$nb_user_not_mail_JC." jamais connectés : ".$total_not_mail_JC." %)</td>
</tr>
<tr>
  <td><strong>".$nb_users_etu." avec Role étudiant</strong> <br />(".$nb_users_etu_JC." jamais connectés : ".$total_role_etu_JC." %)</td>
  <td>".$nb_user_email_role_etu."<br />(".$nb_user_email_role_etu_JC." jamais connectés : ".$total_email_role_etu_JC." %)</td>
  <td>".$nb_user_not_email_role_etu."<br />(".$nb_user_not_email_role_etu_JC." jamais connectés : ".$total_not_email_role_etu_JC." %)</td>
</tr>
<tr>
  <td><strong>".$nb_users_prof." avec Role enseignant</strong> <br />(".$nb_users_prof_JC." jamais connectés : ".$total_role_prof_JC." %)</td>
  <td>".$nb_user_email_role_prof."<br />(".$nb_user_email_role_prof_JC." jamais connectés : ".$total_email_role_prof_JC." %)</td>
  <td>".$nb_user_not_email_role_prof."<br />(".$nb_user_not_email_role_prof_JC." jamais connectés : ".$total_not_email_role_prof_JC." %)</td>
</tr>
<tr>
  <td><strong>".$nb_users_not_etu." avec Role différent d'étudiant et d'enseignant</strong>  <br />(".$nb_users_not_etu_JC." jamais connectés : ".$total_role_not_etu_JC." %)</td>
  <td>".$nb_user_email_not_role."<br />(".$nb_user_email_not_role_JC." jamais connectés : ".$total_email_not_role_JC." %)</td>
  <td>".$nb_user_not_email_not_role."<br />(".$nb_user_not_email_not_role_JC." jamais connectés : ".$total_not_email_not_role_JC." %)</td>
</tr>
</table>";


// UTILISATEUR AVEC AUCUN ROLE
$sql_aucun_role = "SELECT DISTINCT (id) FROM ".$CONF_moodle_bdd_prefixe."user WHERE id NOT IN (
SELECT DISTINCT (userid) FROM ".$CONF_moodle_bdd_prefixe."role_assignments)";
$user_aucun_role = mysql_query($sql_aucun_role);
$nb_user_aucun_role=mysql_num_rows($user_aucun_role);
echo "<h2>Personnes n'ayant aucun role sur Moodle : ".$nb_user_aucun_role." </h2>";

// COMTPE TEMPORAIRE
$sql_tempo = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."user where email!='' AND email NOT LIKE '%".$CONF_domaine."%' AND deleted=0 ";  
$user_tempo = mysql_query($sql_tempo);
//On compte combien ils sont
$nb_user_tempo=mysql_num_rows($user_tempo);
$nb_user_tempo=$nb_user_tempo-1; //le -1 correspond a l'utilisateur ayant l'email root@localhost
echo "<h2>Nb de compte temporaire : ".$nb_user_tempo."</h2>";



$sql_etu_corresp = "SELECT distinct(NO_ETUDIANT) FROM ".$CONF_bdd_prefixe."aua_etudiant_etape` WHERE NO_ANNEE=2009"; 
$etu_corresp = mysql_query($sql_etu_corresp);
$nb_etu_corresp=mysql_num_rows($etu_corresp);
echo "<h2>Nb étudiants distinct ayant une etape 2009 (Apogé) : ".$nb_etu_corresp."</h2><br />";


//Nombre de cours ayant au moins un forum sur Moodle (autre que Forum des nouvelles)
$sql="SELECT count(distinct course) as nb FROM ".$CONF_moodle_bdd_prefixe."forum where name !='Forum des nouvelles'";
$nb_forum_sql = mysql_query($sql);
$nb_forum=mysql_fetch_object($nb_forum_sql);
echo "<h2>Nombre de cours ayant au moins un forum sur Moodle (autre que Forum des nouvelles) : ".$nb_forum->nb."</h2>";


//Nombre de cours proposant des devoirs sur Moodle
$sql="SELECT count(distinct course) as nb FROM ".$CONF_moodle_bdd_prefixe."assignment";
$devoir_sql = mysql_query($sql);
$nb_devoir=mysql_fetch_object($devoir_sql);
echo "<h2>Nombre de cours proposant des devoirs sur Moodle : ".$nb_devoir->nb."</h2>";


//Nombre de cours proposant des QCM sur Moodle 
$sql="SELECT count(distinct course) as nb  FROM ".$CONF_moodle_bdd_prefixe."quiz";
$nb_quiz_sql = mysql_query($sql);
$nb_quiz=mysql_fetch_object($nb_quiz_sql);
echo "<h2>Nombre de cours proposant des QCM sur Moodle : ".$nb_quiz->nb."</h2><br />";


/////////////////////////////////////////////

/////////////////////////////////////////////
//Ressources
 //On prend toutes les ressources mis en fichier
$sql_res = "SELECT * FROM ".$CONF_moodle_bdd_prefixe."resource WHERE type='file'"; 
$ressource_file = mysql_query($sql_res);
//compteur de ressources
$i=0;
//Tableau d'incrementation de nombre de ressources
$tab = array('Image' => 0, 
            'Audio' => 0,
            'Video' => 0, 
            'Texte' => 0, 
            'Diaporama' => 0, 
            'Feuille de calcul' => 0, 
            'Multimedia' => 0,
            'Fichier Compressé' => 0, 
            'Autres' => 0);
//tableau pour les descriptions des extensions associées
$tab_descr = array('Image' => ".gif, .jpg, .jpe, jpeg, .bmp, .png, .tif, tiff, .psd", 
            'Audio' => ".wma, .mp3, .mid",
            'Video' => ".wmv, .avi, .mp4, .flv, .mov, .mpg, .asf, .ogg", 
            'Texte' => ".pdf, .txt, .odt, .doc, .rtf", 
            'Diaporama' => ".pps, .odp, .ppt", 
            'Feuille de calcul' => ".ods, .xls, .odt", 
            'Multimedia' => ".swf", 
            'Fichier Compressé' => ".zip, .rar", 
            'Autres' => "Lien internet,..."); 
//Pour chaque ressource
while($ressource=mysql_fetch_object($ressource_file)){
    //On verifie qu'il y a bien un nom de ficheir
    if(isset($ressource->reference) AND $ressource->reference!=NULL){
    //On récupère l'extension; exemple : .avi 
    //On aurai pu récupéré tout ce qu'ily  a apres le dernier point, mais certaines fois les extension sont du genre .php?page=annuaire,...
    $extension=substr($ressource->reference, -4,4);
    //Selon l'extension, on incrémente telle ou telle catégorie
    switch ($extension) {
      case ".gif":
      case ".jpg":
      case ".jpe":
      case "jpeg":
      case ".bmp":
      case ".png":
      case ".tif":
      case "tiff":
      case ".psd":
          $tab['Image']=$tab['Image']+1;
          break;
      case ".wma":
      case ".mp3":
      case ".mid":
          $tab['Audio']=$tab['Audio']+1;
          break;
      case ".wmv":
      case ".avi":
      case ".mp4":
      case ".flv":
      case ".mov":
      case ".mpg":
      case ".asf":
      case ".ogg":
          $tab['Video']=$tab['Video']+1;
          break;
      case ".pdf":
      case ".txt":
      case ".odt":
      case ".doc":
      case ".rtf":
          $tab['Texte']=$tab['Texte']+1;
          break;
      case ".pps":
      case ".odp":
      case ".ppt":
          $tab['Diaporama']=$tab['Diaporama']+1;
          break;
      case ".ods":
      case ".xls":
          $tab['Feuille de calcul']=$tab['Feuille de calcul']+1;
          break;
      case ".swf":
          $tab['Multimedia']=$tab['Multimedia']+1;
          break;
      case ".zip":
      case ".rar":
          $tab['Fichier Compressé']=$tab['Fichier Compressé']+1;
          break;
      default:
          $tab['Autres']=$tab['Autres']+1;
    }
    $i++;//compteur de ressources
}
}

echo "<h2>Ressources : ".$i."</h2>";
$affiche_tableau = "<table class='ui-widget ui-widget-content' style='font-size:13px;'>
<thead class='ui-widget-header'><tr><th>Type</th><th>Extensions</th><th>Nombre de ressources</th></tr></thead>";
//Pour chaque valeur du tableau on affiche les resultats
foreach($tab as  $cle => $valeur){
  $affiche_tableau.="<tr><td>".$cle."</td><td>".$tab_descr[$cle]."</td><td>".$valeur."</td></tr>";
}
$affiche_tableau.="<tr><td><b>TOTAL</b></td><td> </td><td><b>".$i."</b></td></tr>";
$affiche_tableau.="</table>";
echo $affiche_tableau;

/////////////////////////////////////////////
   

?>